<template>
	<view class="" style="padding:12px">
		<view class="flex-ju-b bgfff mb10" v-for="(item,index) in list" :key="index" style="padding:10px;border-radius: 5px;" >
			<view class="flex">
				<image mode="widthFix" style="width:70px;" class="mr5" :src="item.goods_image"></image>
				<view >
					<view class="mt5 mb5">{{item.goods_name}}</view>
					<view style="font-size: 12px;">
						转赠时间：{{item.create_time}}
					</view>
				</view>
			</view>
			<view @click="cenmr(item)" v-if="item.status==0" class="pay_btn " >取消转赠</view>
			<view v-else :style="{color:item.status==1?'#248c85':'#ccc'}" >{{item.status_cn}}</view>
			
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:[]
			}
		},
		mounted() {
			this.$http('v1.user_transfer_list').then((res) => {
				
				this.list = res.data
			})
		},
		methods: {
			cenmr(item){
				uni.showModal({
					content:"确定要取消吗?",
					success:(res)=> {
						if(res.confirm){
							this.$http('v1.cancel_transfer',{
								id:item.transfer_id
							},'请稍等').then((res) => {
								if (res.data.status == 0) {
									uni.showToast({
										title:res.data.msg,
										icon:"none"
									})
								}else{
									item.status=2
									item.status_cn='已回收'
									uni.showToast({
										title:"取消成功",
										icon:"none"
									})
								}
							})
						}
					}
				})
			},
		}
	}
</script>

<style>
	.pay_btn {
		width: 200rpx;
		white-space: normal;
		padding:0 10px;
	    font-size: 12px;
		height: 70rpx;
		background: #a084f0;
		border-radius: 168rpx 168rpx 168rpx 168rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: 400;
		color: #ffffff;
		line-height: 70rpx;
		text-align: center;
	}
</style>
